package com.disruptor.akka;

import akka.actor.UntypedAbstractActor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by mengdexuan on 2017/9/20 17:17.
 */
public class MyWork extends UntypedAbstractActor{

	private Logger log = LoggerFactory.getLogger(getClass());

	public static enum Msg{
		WORKING,DONE,CLOSE;
	}

	@Override
	public void onReceive(Object o) throws Throwable {
		if (o==Msg.WORKING){
			log.info("working...");
		}else if (o==Msg.DONE){
			log.info("done...");
		}else if (o==Msg.CLOSE){
			log.info("close...");
			getSender().tell(Msg.CLOSE,getSelf());
			getContext().stop(getSelf());
		}else {
			unhandled(o);
		}
	}

}
